// src/renderer/models/up_request.ts

export type Parity = 'none' | 'even' | 'odd';
export type FlowControl = 'none' | 'xon/xoff' | 'rts/cts';

export interface OpenSerialRequest {
  device: string;
  baudrate: number;
  parity: Parity;
  databits: number;
  stopbits: number;
  flowcontrol: FlowControl;
  timeout: number;
}

export interface SerialRequest {
  serial_id: string;
}

export interface HttpRequest extends SerialRequest {
  protocol_id: number;
}

export interface WriteRequest extends SerialRequest {
  raw_data: string;
}

export interface AngleRequest extends HttpRequest {
  angle: number;
}

export interface AngleRpmRequest extends HttpRequest {
  angle: number;
  rpm: number;
}

export interface AngleLimitRequest extends HttpRequest {
  min: number;
  max: number;
}

export interface VoltageLimitRequest extends HttpRequest {
  min: number;
  max: number;
}

export interface SpeedRequest extends HttpRequest {
  rpm: number;
}

export interface LoadInfoRequest extends HttpRequest {
  interval: number;
}

export enum EEPromParam {
  GetSoftwareVersion = 'buildGetSoftwareVersion',
  GetID = 'buildGetID',
  GetBaudrate = 'buildGetBaudrate',
  GetReturnDelayTime = 'buildGetReturnDelayTime',
  GetMaxTemperature = 'buildGetMaxTemperature',
  GetMinVoltage = 'buildGetMinVoltage',
  GetMaxVoltage = 'buildGetMaxVoltage',
  GetStatusReturnLevel = 'buildGetStatusReturnLevel',
  GetAlarmLED = 'buildGetAlarmLED',
  GetAlarmShutdown = 'buildGetAlarmShutdown',
  GetAngleLimit = 'buildGetAngleLimit',
  GetCwAngleLimit = 'buildGetCwAngleLimit',
  GetCcwAngleLimit = 'buildGetCcwAngleLimit',
  GetVoltageRange = 'buildGetVoltageRange',
  GetMaxTorque = 'buildGetMaxTorque',
}

export enum RAMParam {
  GetTorqueEnabled = 'buildGetTorqueEnabled',
  GetLEDEnabled = 'buildGetLEDEnabled',
  GetCwComplianceMargin = 'buildGetCwComplianceMargin',
  GetCcwComplianceMargin = 'buildGetCcwComplianceMargin',
  GetCwComplianceSlope = 'buildGetCwComplianceSlope',
  GetCcwComplianceSlope = 'buildGetCcwComplianceSlope',
  GetAcceleration = 'buildGetAcceleration',
  GetDeceleration = 'buildGetDeceleration',
  GetVoltage = 'buildGetVoltage',
  GetTemperature = 'buildGetTemperature',
  CheckRegWriteFlag = 'buildCheckRegWriteFlag',
  CheckMovingFlag = 'buildCheckMovingFlag',
  GetLockFlag = 'buildGetLockFlag',
  GetGoalPosition = 'buildGetGoalPosition',
  GetRunSpeed = 'buildGetRunSpeed',
  GetPosition = 'buildGetPosition',
  GetSpeed = 'buildGetSpeed',
  GetAccelerationDeceleration = 'buildGetAccelerationDeceleration',
  GetLoad = 'buildGetLoad',
  GetMinPWM = 'buildGetMinPWM',
}

export enum EEPromParamWrite {
  SetID = 'buildSetID',
  SetBaudrate = 'buildSetBaudrate',
  SetReturnDelayTime = 'buildSetReturnDelayTime',
  SetMaxTemperature = 'buildSetMaxTemperature',
  SetMaxTorque = 'buildSetMaxTorque',
  SetAlarmLED = 'buildSetAlarmLED',
  SetAlarmShutdown = 'buildSetAlarmShutdown',
}

export interface EEPromParamRequest extends HttpRequest {
  param: EEPromParam;
}

export interface RAMParamRequest extends HttpRequest {
  param: RAMParam;
}

export interface EEPromParamWriteRequest extends HttpRequest {
  param: EEPromParamWrite;
  value: number;
}

export interface AccelerationDecelerationRequest extends HttpRequest {
  acceleration: number;
  deceleration: number;
}
